function plus(id, stock) {
    var va = document.getElementById(id).value;
    if (va >= stock) {
        return;
    }
    location.href = "shop/update?id=" + id + "&action=jia";

}

function sub(id) {
    // 该商品的原本数量
    var va = document.getElementById(id).value;
    // 减数量不能小于1
    if (va <= 1) {
        return;
    }
    location.href = "shop/update?id=" + id + "&action=jian";

}

function closeText(id, stock) {
    var va = document.getElementById(id).value;
    if (va < 1) {
        alert('您输入的数量不能小于1！！！')
        document.getElementById(id).value = 1;
        va = 1;
    }
    if (va > stock) {
        alert('您输入的数量超出库存！！！');
        document.getElementById(id).value = stock;
        va = stock;
    }
    location.href = "shop/update?id=" + id + "&value=" + va + "&action=closeText";
}

function del(id) {
    if (confirm("确定要删除吗？")) {
        location.href = "shop/update?id=" + id + "&action=delText";
    }
}


var fxi = 0;

function qxcheck() {

    var op2 = document.getElementsByName("op2");
    var op = document.getElementsByName("op");

    if (fxi == 0) {
        for (var i = 0; i < op.length; i++) {
            op[i].checked = true;
        }
        fxi = 1;
    } else {
        for (var i = 0; i < op.length; i++) {
            op[i].checked = false;
        }
        fxi = 0;
    }
    dxcheck();
}

function dxcheck() {
    var sum = 0;
    var op = document.getElementsByName("op");
    var price = document.getElementsByName("priceText");
    var number = document.getElementsByName("number");
    for (var i = 0; i < op.length; i++) {
        if (op[i].checked) {
            sum += parseInt(parseInt(price[i].innerText) * parseInt(number[i].value));
        }
    }

    document.getElementById("zdzj").innerHTML = sum;
    document.getElementById("jstext").value = sum;
    var money = document.getElementById("zdzj").innerText;
    if (money == "0") {
        document.getElementById("jsbutton").style.display = 'none';
        document.getElementById("xzText").hidden = false;
    } else {
        document.getElementById("xzText").hidden = true;
        document.getElementById("jsbutton").style.display = 'inline';
    }
}